<template>
  <div style="height: 100%">
    <Add v-if="showAdd" :farmland-detail="currentFarmland" @back="showAdd = false" />
    <div class="farmland-page">
      <div class="f-r j-b">
        <el-form inline class="f-g">
          <el-form-item label="排序方式">
            <SwitchTabs v-model="searchParams.value" :data="[{ name: '默认', value: '1'},{ name: '创建时间', value: '2'}, ]" />
          </el-form-item>
          <el-form-item label="面积">
            <SwitchTabs v-model="searchParams.value" :data="[{ name: '大', value: '1'},{ name: '小', value: '2'}, ]" />
          </el-form-item>
          <el-form-item label="查看方式">
            <SwitchTabs v-model="searchParams.way" :data="[{ name: '图标', value: '1'},{ name: '列表', value: '2'}, ]" />
          </el-form-item>
        </el-form>
        <div>
          <el-button type="primary" icon="el-icon-plus" @click="add">新增田</el-button>
        </div>
      </div>
      <el-form inline>
        <el-form-item label="组织架构">
          <el-input v-model="searchParams.value" clearable placeholder="" />
        </el-form-item>
        <el-form-item label="田分组">
          <el-input v-model="searchParams.value" clearable placeholder="" />
        </el-form-item>
        <el-form-item label="选择作物">
          <el-input v-model="searchParams.value" clearable placeholder="" />
          <el-input v-model="searchParams.value" clearable placeholder="" style="margin-left: 20px" />
          <el-button type="primary" style="margin-left: 15px">搜索</el-button>
        </el-form-item>
      </el-form>
      <div class="border" />
      <div class="content">
        <div class="header f-r a-c j-b">
          <div class="f-r a-c">
            <span class="title">田块个数：</span>
            <span class="value">221块</span>
            <span class="title">田块总面积：</span>
            <span class="value">18692.70亩</span>
          </div>
          <SwitchTabs
            v-model="componentName"
            style="margin-right: 0"
            :data="[{ name: '列表模式', value: 'FarmlandC'},{ name: '田分组', value: 'FarmlandGroup'},{ name: '地图模式', value: 'Map2'}, ]"
            @change="(val) => $emit('change', val)"
          />
        </div>
        <div v-show="searchParams.way === '1'" class="row-list f-r f-w">
          <div v-for="item in tableData" :key="item.id" class="row-box" @click="view(item)">
            <div class="row-item">
              <div class="tag">苹果</div>
              <div class="name-wrapper">
                <div class="name">余杭xxxx田块</div>
                <div class="desc">小麦，97亩8分</div>
                <img class="avatar">
              </div>
            </div>
          </div>
        </div>
        <div v-show="searchParams.way === '2'" class="table-box">
          <el-table
            v-loading="loading"
            stripe
            :data="tableData"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(255, 255, 255, 0.8)"
            @selection-change="onSelect"
          >
            <el-table-column type="index" align="center" label="序号" />
            <el-table-column
              v-for="item in columns"
              :key="item.prop"
              :prop="item.prop"
              :label="item.label"
              :align="item.align || 'center'"
              :min-width="item.minWidth"
            />
            <el-table-column label="操作" fixed="right" width="160px"><template slot-scope="scope">
              <el-button
                type="text"
              >冻结账户</el-button>
              <el-button
                type="text"
              >下级成员</el-button>
              <el-button
                type="text"
              >分田</el-button>
              <el-button
                type="text"
              >查看田块(13)</el-button>
            </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="page-box">
          <el-pagination
            background
            :current-page="pageNo"
            :page-sizes="pageSizes"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalSize"
            @size-change="changePageSize"
            @current-change="changePageNo"
          />
        </div>
      </div>
    </div>
  </div>

</template>

<script>
import crud from '@/mixins/crud';
import Add from './add'
export default {
  name: 'Farmland2',
  components: {
    Add
  },
  mixins: [crud],
  data() {
    return {
      searchParams: {
        value: '1',
        way: '1'
      },
      data: [
        { value: 1, label: 'dasd' }
      ],
      columns: [
        { prop: '1', label: '田块名称', minWidth: '' },
        { prop: '2', label: '作物', minWidth: '' },
        { prop: '3', label: '品种', minWidth: '120px' },
        { prop: '4', label: '面积', minWidth: '' },
        { prop: '5', label: '地址', minWidth: '400px' },
        { prop: '6', label: '创建人', minWidth: '' },
        { prop: '7', label: '负责人', minWidth: '' },
        { prop: '8', label: '联系方式', minWidth: '' }
      ],
      tableData: [
        {}
      ],
      componentName: 'FarmlandC',
      // 新增田块
      showAdd: false,
      // 查看田块
      showView: false,
      // 当前田块
      currentFarmland: null
    }
  },
  methods: {
    add() {
      this.currentFarmland = null
      this.showAdd = true
    },
    view(rowItem) {
      this.showView = true
      this.currentFarmland = rowItem
    }
  }

}
</script>

<style scoped lang="scss">
.farmland-page {
  position: relative;
  padding: 20px;
  background-color: #ffffff;
  height: 100%;
  .el-form-item {
    margin-bottom: 22px;
  }
  .border {
    border-top: 1px solid #E8E8E8;
    margin-bottom: 27px;
  }
  .row-list {
    .row-box {
      width: 20%;
      padding: 12px 10px;
      .row-item {
        cursor: pointer;
        width: 100%;
        height: 159px;
        box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);
        position: relative;
        border-radius: 14px;
        background-color: #2b2f3a;
        .tag {
          position: absolute;
          left: 11px;
          top: -5px;
          width: 36px;
          height: 16px;
          background: #1AAD23;
          line-height: 16px;
          text-align: center;
          color: #ffffff;
          font-size: 12px;
        }
        .name-wrapper {
          padding: 2px 0 0 11px;
          height: 53px;
          position: absolute;
          left: 0;
          bottom: 0;
          width: 100%;
          background-color: #ffffff;
          border-radius:0 0 14px 14px;
          overflow: hidden;
          .avatar {
            position: absolute;
            width: 35px;
            height: 35px;
            box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);
            opacity: 1;
            border: 1px solid #707070;
            border-radius: 50%;
            overflow: hidden;
            top: -12px;
            right: 14px;
            background-color: #ffffff;
            z-index: 999;
          }
          .name {
            font-size: 14px;

            font-weight: 400;
            color: #595959;
            line-height: 22px;
          }
          .desc {
            margin-top: 5px;
            font-size: 12px;

            font-weight: 400;
            color: #595959;
            line-height: 22px;
          }
        }
      }
    }
  }
  .header {
    .title {
      font-size: 16px;

      font-weight: 400;
      color: #222222;
      line-height: 24px;
    }
    .value {
      font-size: 16px;
      font-family: Source Han Sans CN-Regular, Source Han Sans CN;
      font-weight: 400;
      color: #1AAD23;
      line-height: 14px;
      margin-right: 23px;
      font-weight: bold;
    }
  }
}
</style>
